var t = getApp();

Page({
    data: {
        RenewShow: !1,
        listData: [],
        renewUserId: "",
        owner_goods_count: "",
        owner_goods_id: "",
        goodsTotal: 1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "债权人"
        }), this.setData({
            plugin_setting: wx.getStorageSync("yz_basic_info").plugin_setting.debt_shop || {},
            RenewShow: !1
        });
    },
    tapclose: function() {
        this.setData({
            RenewShow: !1
        });
    },
    toShop: function(t) {
        var e = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageF/debt/debtor/debtorShop/debtorShop?kid=" + e + "&member_type=1"
        });
    },
    toApply: function() {
        wx.navigateTo({
            url: "/packageF/debt/debtapply/debtapply?type=1"
        });
    },
    renewTap: function(t) {
        var e = t.currentTarget.dataset.item.has_one_owner.id;
        this.setData({
            RenewShow: !0,
            renewUserId: e
        }), this.getApplyData();
    },
    onReady: function() {},
    onShow: function() {
        this.getdebtListInit(), this.getData(), this.getdebtList();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    getdebtListInit: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            listData: []
        });
    },
    stepperTap: function(t) {
        var e = t.detail;
        this.setData({
            goodsTotal: e
        });
    },
    renewPost: function() {
        var e = this, a = this;
        if (this.data.goodsTotal > this.data.owner_goods_count) wx.showToast({
            icon: "none",
            title: "拥有商品数量不足",
            duration: 1500
        }); else {
            var o = {
                id: this.data.renewUserId,
                count: this.data.goodsTotal
            }, n = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.rechargeDebtMemberTime");
            t._getNetWork({
                url: n,
                data: o,
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? (e.setData({
                        RenewShow: !1
                    }), wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1e3,
                        success: function() {
                            a.getdebtListInit(), a.getData(), a.getdebtList();
                        }
                    })) : wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getApplyData: function() {
        var e = this, a = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.applyData");
        t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result && e.setData({
                    owner_goods_count: a.data.owner_goods_count,
                    owner_goods_id: a.data.owner_goods_id
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goGoods: function() {
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + this.data.owner_goods_id
        });
    },
    getData: function() {
        var e = this, a = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.getDebtData");
        t._getNetWork({
            url: a,
            data: {
                member_type: 1
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? e.setData({
                    userInfo: a.data
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getdebtList: function() {
        var e = this, a = t.getNetAddresss("plugin.debt-shop.frontend.owner.debtorList");
        t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (console.log(a), e.data.isLoadMore = !0, e.data.total_page = a.data.last_page, 
                e.data.total_page || (e.data.total_page = 0), e.setData({
                    listData: a.data.data
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var a = t.getNetAddresss("plugin.debt-shop.frontend.owner.debtorList");
            t._getNetWork({
                url: a,
                data: {
                    page: this.data.page
                },
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (e.data.isLoadMore = !0, e.setData({
                        listData: a.data.data
                    })) : (e.data.page = e.data.page - 1, e.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});